﻿using System;
using Microsoft.Xna.Framework;

    static class MyMaths
    {
        public static Random rand = new Random();

        public static double DegToRad(double angle)
        {   
            return Math.PI * angle / 180.0;
        }

        public static void bound(ref float _n, float _min, float _max)
        {
            if (_n < _min)
                _n = _min;
            else if (_n > _max)
                _n = _max;
        }

        public static void rotateVector(ref Vector2 _aVec, float _rads)
        {
            _aVec.X = (float)(Math.Cos(_rads) * _aVec.X - Math.Sin(_rads) * _aVec.Y);
            _aVec.Y = (float)(Math.Sin(_rads) * _aVec.X + Math.Cos(_rads) * _aVec.Y);
        }

        // not tested this yet
        public static void rotatePointAroundPoint(ref Vector2 _point, Vector2 _origin, float _rad)
        {
            Vector2 diff = _point - _origin;
            rotateVector(ref diff, _rad);
            _point = _origin + diff;
        }

    }
